{extend name="layout/common_layout" /}
{block name="body"}
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/goods/index')}">商品管理</a></li>
            <!--<li class=""><a href="{:url('admin/goods/add')}">添加商品</a></li>-->
            <li class="layui-this">商品详情</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="{$goods.title}" required  lay-verify="required" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">商品种类</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="{$floor1.name}" required  lay-verify="required" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">商品分类</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="{$floor2.name}" required  lay-verify="required" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">商品规格</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="{$spec.name}" required  lay-verify="required" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">商品单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="{$unit.name}" required  lay-verify="required" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">商品图片</label>
                        <div class="layui-input-block">
                            {foreach name="$goods['photo']" item="v"}
                            <img src="{$v}" style="width: 100px;"/>
                            {/foreach}
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发布人</label>
                        <div class="layui-input-block">
                            <input type="text" name="author" value="{$user.username}" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="author" value="{$goods.phone}" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">单价</label>
                        <div class="layui-input-block">
                            <input type="text" name="price" value="{$goods.price}" lay-verify="required" class="layui-input" disabled="disabled">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">简介</label>
                        <div class="layui-input-block">
                            <textarea name="introduction" class="layui-textarea" disabled="disabled">{$goods.content}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发布时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="publish_time" value="{$goods.ctime}" class="layui-input datetime" disabled="disabled">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
{/block}
{block name="js"}
<!--<script src="__JS__/kindeditor/kindeditor.config.js"></script>-->
<!--<script src="__JS__/kindeditor/kindeditor-all-min.js"></script>-->
<script src="__JS__/ueditor/ueditor.config.js"></script>
<script src="__JS__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="script"}
<script>
    //文件上传
    layui.upload({
        url: "/index.php/api/upload/upload",
        type: 'file',
        elem:'#attar',
        success: function (data) {
            if (data.error === 0) {
                document.getElementById('file').value = data.url;
            } else {
                layer.msg(data.message);
            }
        }
    });

    $(function() {
        var ue = UE.getEditor('content'),
            uploadEditor = UE.getEditor('upload-photo-btn'),
            photoListItem,
            uploadImage;

        uploadEditor.ready(function () {
            uploadEditor.setDisabled();
            uploadEditor.hide();
            uploadEditor.addListener('beforeInsertImage', function (t, arg) {
                $.each(arg, function (index, item) {
                    photoListItem = '<div class="photo-list"><input style="display: none;" type="text" name="photo[]" value="' + item.src + '" class="layui-input layui-input-inline">';
                    photoListItem += '<img src="' + item.src + '" style="width:100px;"/>';
                    photoListItem += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button></div>';

                    $('#photo-container').append(photoListItem).on('click', '.remove-photo-btn', function () {

                        $(this).parent('.photo-list').remove();
                    });

                });
            });
        });

        $('#upload-photo-btn').on('click', function () {
            uploadImage = uploadEditor.getDialog("insertimage");
            uploadImage.open();
        });



        $('.remove-photo-btn').click(function(){

            $(this).parent('.photo-list').remove();
        });
    });

//    $(document).ready(function () {
//        var _kindEditor;
//        KindEditor.ready(function(K) {
//            _kindEditor = K.create('#content', KindEditorOptions);
//
//            K('#upload-photo-btn').click(function () {
//                var photo_list_item = '';
//                _kindEditor.loadPlugin('multiimage', function() {
//                    _kindEditor.plugin.multiImageDialog({
//                        showRemote : false,
//                        imageUrl : K('#photo').val(),
//                        clickFn : function(data) {
//                            $.each(data, function (index, item) {
//                                photo_list_item += '<div class="photo-list"><input type="text" name="photo[]" value="' + item.url + '" class="layui-input layui-input-inline">';
//                                photo_list_item += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button></div>'
//                            });
//                            $('#photo-container').append(photo_list_item);
//                            _kindEditor.hideDialog();
//                        }
//                    });
//                });
//            });
//        });
//
//        $('#photo-container').on('click', '.remove-photo-btn', function () {
//            $(this).parent('.photo-list').remove();
//        });
//    });
</script>
{/block}